package com.gl.battleship.services.controllers;

import java.util.List;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.gl.battleship.domain.Notification;
import com.gl.battleship.domain.User;
import com.gl.battleship.domain.response.BattleshipResponse;
import com.gl.battleship.services.exceptions.GameException;

/**
 *
 * @author simon.gomez
 * @author romina.tornello
 * @author mariana.capponetto
 * @author armando.rosario
 * @version 1.0
 * 
 * Interface for REST services
 * Send data format is "{method name} / {parameter 1} / {parameter 2}"
 * The notation @PathVariable indicating that parameter as received 
 * with each service method argument
 * 
 */

@Controller
public interface IRestBattleshipServices {	
	
	/**
	 * Login 
	 * 
	 * @param user is the user name who want to enter in the game 
	 * @param password is the password who want to enter in the game
	 * @return securityToken is an string that identified the user
	 */
	@RequestMapping("/login/{username}/{password}")
	@ResponseBody
	public BattleshipResponse login(@PathVariable("username") String user,@PathVariable("password") String pass);
	
	
	/**
	 * Logout 
	 * 
	 * @param securityToken is the String that identified the user
	 * @return 'VALID' is an String that confirms the user unlogged
	 * 
	 */
	@RequestMapping("/logout/{securityToken}")
	@ResponseBody
	public BattleshipResponse logout(@PathVariable("securityToken") String securityToken);
	
	
	/**
	 * Get the users for states
	 * 
	 * @param securityToken is the security token of the user that requires the list
	 * @param userState is the state of the user list required: ALL,AVAILABLE,NOTAVAILABLE.
	 * @return List of users for the state required 
	 * 
	 */
	@RequestMapping("/getUsersByState/{securityToken}")
	@ResponseBody
	public BattleshipResponse getUsersByState(@PathVariable("securityToken") String securityToken);
	
	
	/**
	 * Get the users in all states
	 * 
	 * @param securityToken is the security token of the user that requires the list
	 * @return List all the users: AVAILABLE and NOTAVAILABLE.
	 * 
	 */
	@RequestMapping("/getUsersByState/{securityToken}/{userState}")
	@ResponseBody
	public BattleshipResponse getUsersByState(@PathVariable("securityToken") String securityToken,@PathVariable("userState") String userState);
	
	
	/**
	 * User declares war on another user
	 * 
	 * @param securityToken SecurityToken of user who declared the war
	 * @param opponent is the nick of opponent user 
	 * @return warToken, is an String that identified the war declared, or 'INVALID PARTICIPANT' 
	 * 
	 */
	@RequestMapping("/declareWar/{securityToken}/{opponent}")
	@ResponseBody
	public BattleshipResponse declareWar(@PathVariable("securityToken") String securityToken, 
			@PathVariable("opponent") String opponent);
	
	
	/**
	 * Accept the participant(opponent) to start the war
	 * 
	 * @param securityToken is a String that identified the participant who accepted the war
	 * @param warToken is a String that identified the war declared
	 * @return answerToWar is an String,'VALID', that confirms the war accepted 
	 * 
	 */
	@RequestMapping("/acceptWar/{securityToken}/{warToken}")
	@ResponseBody
	public BattleshipResponse acceptWar(@PathVariable("securityToken") String securityToken, 
			@PathVariable("warToken") String warToken);
	
	
	/**
	 * refusetWar 
	 * 
	 * @param securityToken received in login for validate session
	 * @param warToken contains the token with the war that want to refuse
	 * @return answerToWar is an String,'VALID', that confirms the war refused 
	 * 
	 */
	@RequestMapping("/refuseWar/{securityToken}/{warToken}")
	@ResponseBody
	public BattleshipResponse refuseWar(@PathVariable("securityToken") String securityToken, 
			@PathVariable("warToken") String warToken);
	
	/**
	 * Retired the war declared
	 * 
	 * @param user is the User who canceled the war
	 * @param warToken is an String that identified the war declared
	 * @return a String 'RETIRED' that confirms the war canceled
	 * @throws GameException 
	 */	
	@RequestMapping("/retiredWar/{nick}")
	@ResponseBody
	public BattleshipResponse retiredWar(@PathVariable("nick") String nick);
	
	
	/**
	 * validate the Fleet created for the player 
	 * 
	 * @param securityToken received in login for validate session
	 * @param warToken contains the token with the war that want to validate the fleet
	 * @param fleet contains a string with the player's board and the fleet
	 * @return answerToWar is an String,'VALID', that confirms the fleet created
	 * 
	 */
	@RequestMapping("/validateFleet/{securityToken}/{warToken}/{fleet}")
	@ResponseBody
	public BattleshipResponse validateFleet(@PathVariable("securityToken") String securityToken, 
			@PathVariable("warToken") String warToken, @PathVariable("fleet") String fleet);
	
	
	/**
	 * shoot 
	 * 
	 * @param securityToken received in login for validate session
	 * @param warToken contains the token with the war that want to shoot
	 * @param x horizontal position for shoot
	 * @param y vertical position for shoot
	 * @return WATER, HIT, HIT/SUNK, HIT/SUNK/WIN according to shooting
	 * 
	 */
	@RequestMapping("/shoot/{securityToken}/{warToken}/{x}/{y}")
	@ResponseBody
	public BattleshipResponse shoot(@PathVariable("securityToken") String securityToken, 
			@PathVariable("warToken") String warToken, @PathVariable("x") int x, 
			@PathVariable("y") String y);
	
	
	/**
	 * Get Notifications of an user 
	 * 
	 * @param nick is the nick name of the user
	 * @return List <Notification> of the user called whit this nick
	 */
	@RequestMapping("/getNotification/{nick}")
	@ResponseBody
	public BattleshipResponse getNotification(@PathVariable("nick") String nick);
	
	
}
